<template>
	<!-- 注资 -->
	<view class="assetInject2">
		<view class="in_storageMain animate__animated animate__fadeIn">
			<view class="in_storageMain1">
				<view class="text">注资金额：</view>
				<input type="text" v-model="inputs.investmentAmount" />
			</view>
			<view class="in_storageMain1">
				<view class="text">收款方式：</view>
				<picker mode="selector" :range="options" @change="onPickerChange">
					<view class="picker" style="color: #9c9c9c">{{ selectedOption || '点击选择' }}</view>
				</picker>
			</view>

			<button class="submit" @click="submit">注资</button>
		</view>
	</view>
</template>

<script>
import logComponentVue from '../../components/index/logComponent.vue';
import { request } from '../../request';
import 'animate.css';
export default {
	data() {
		return {
			inputs: {
				investmentAmount: null,
				publicCollect: null,
				cashCollect: null,
				bill: 2
			},
			options: ['账户', '现金'], // 下拉选项
			selectedOption: '账户' // 当前选中的选项
		};
	},
	methods: {
		onPickerChange(e) {
			const index = e.detail.value; // 获取选中的索引
			this.selectedOption = this.options[index]; // 更新选中的值
		},
		submit() {
			// 设置资金接受账户
			if (this.selectedOption == '现金') {
				this.inputs.cashCollect = this.inputs.investmentAmount;
				this.inputs.publicCollect = 0;
			} else if (this.selectedOption == '账户') {
				this.inputs.publicCollect = this.inputs.investmentAmount;
				this.inputs.cashCollect = 0;
			}

			// 发送请求
			request('public/assetInject', this.inputs, 'POST').then((res) => {
				if (res.data.code != 200) {
					this.$message.error('   ' + res.data.msg);
					return;
				}
				this.$message.success('注资成功！');

				uni.navigateBack();
			});
		}
	}
};
</script>

<style scoped>
.assetInject2 {
	display: flex;
	justify-content: center;
	padding: 40rpx 20rpx;
	background-color: #f8f9fa;
	min-height: 1370rpx;
}

.in_storageMain {
	width: 100%;
	max-width: 650rpx;
	background-color: #ffffff;
	border-radius: 20rpx;
	padding: 40rpx 30rpx;
	box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.08);
	height: 700rpx;
	margin-top: 200rpx;
}

.in_storageMain1 {
	width: 100%;
	margin: 30rpx 0;
	display: flex;
	flex-direction: column;
}

.text {
	font-size: 28rpx;
	color: #666666;
	margin-bottom: 15rpx;
	font-weight: 500;
}

input,
.picker {
	width: 92%;
	height: 80rpx;
	border-radius: 12rpx;
	border: 1px solid #e0e0e0;
	padding: 0 25rpx;
	font-size: 28rpx;
	color: #333333;
	transition: all 0.2s ease;
}

input:focus,
.picker:focus {
	border-color: #3498db;
	box-shadow: 0 0 0 2rpx rgba(52, 152, 219, 0.2);
}

.picker {
	display: flex;
	align-items: center;
	background-color: #ffffff;
	position: relative;
}

.picker::after {
	content: '▾';
	position: absolute;
	right: 25rpx;
	color: #999999;
}

.addBill {
	margin-top: 15rpx;
	padding: 15rpx 25rpx;
	background-color: #3498db;
	color: #ffffff;
	border-radius: 10rpx;
	font-size: 26rpx;
	text-align: center;
	transition: all 0.2s ease;
}

.addBill:hover {
	background-color: #2980b9;
}

.BillSelect {
	height: 80rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.BillSelect button {
	margin: 0;
	height: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
}

.BillSelect .picker {
	width: 440rpx !important;
}

.beizhu {
	width: 92%;
	height: 200rpx;
	padding: 20rpx 25rpx;
	border-radius: 12rpx;
	border: 1px solid #e0e0e0;
	font-size: 28rpx;
	color: #333333;
	transition: all 0.2s ease;
	resize: none;
}

.beizhu:focus {
	border-color: #3498db;
	box-shadow: 0 0 0 2rpx rgba(52, 152, 219, 0.2);
}
.submit {
	background-color: #2fb0bc;
	color: white;
	border: 0;
}
.cost {
	width: ;
}
.cost::after {
	content: '元';
	position: absolute;
	right: 50rpx;
	margin-top: -40rpx;
	transform: translateY(-50%);
	color: #999;
	pointer-events: none;
}
</style>
